<%= will_filter_scripts_tag %>

<% if params[:charts] == "true" %>
  <% @metrics.each do |metric| %>
      <div style="width:380px;  background-color:#efefef; float:left; padding:5px; border-radius:10px; margin:5px;">
          <div style="padding:5px;">
              <div style="float:right">
                  <%= tr8n_actions_tag([
                        link_to(image_tag("tr8n/arrow_rotate_clockwise.png"), {:action => :recalculate_metric, :metric_id => metric.id}, {:confirm => "Are you sure you want to recaluclate this metric?"})
                        ]) %>
              </div>
              <div style="font-weight:bold;"><%=image_tag("tr8n/flags/#{metric.language.flag}.png")%> &nbsp; <%=metric.language.english_name%></div>
          </div>
          <%=render :partial => "/tr8n/translator/translation_source_metric", :locals => {:translation_source => metric.translation_source, :translation_source_metric => metric} %>
      </div>
  <% end %>

<% else %>
  <%= will_filter_table_tag(@metrics, :columns => [
      [:flag, lambda{|metric| metric.language ? image_tag("tr8n/flags/#{metric.language.flag}.png") : ''}, 'width:30px;'],
      [:language_id, lambda{|metric| 
         metric.language.english_name
      }],    
      [:key_count, lambda{|metric|
        link_to(metric.key_count, "/tr8n/admin/sources/view?mode=translation_keys&id=#{metric.translation_source.id}")
      }, 'text-align:right'],
      [:translated_key_count, lambda{|metric| 
        metric.translated_key_count
      }, 'padding:5px;text-align:right;white-space:nowrap;'],    
      [:locked_key_count, lambda{|metric| 
        metric.locked_key_count
      }, 'padding:5px;text-align:right;white-space:nowrap;'],    
      [:translation_count, lambda{|metric| 
        metric.translation_count
      }, 'padding:5px;text-align:right;white-space:nowrap;'],    
      [:not_translated, lambda{|metric| 
        metric.not_translated_count
      }, 'padding:5px;text-align:right;white-space:nowrap;'],    
      [:pending_approval, lambda{|metric| 
        metric.pending_approval_count
      }, 'padding:5px;text-align:right;white-space:nowrap;'],    
      [:translation_progress, lambda{|metric| 
        "#{metric.translation_completeness}%"
      }, 'padding:5px;text-align:right;white-space:nowrap;'],    
      [:locked_phrases, lambda{|metric| 
        "#{metric.completeness}%"
      }, 'padding:5px;text-align:right;white-space:nowrap;'],    
      
      [:actions, lambda{|metric|
        tr8n_actions_tag([ 
          link_to("Recalculate", {:action => :recalculate_metric, :metric_id => metric.id}, {:confirm => "Are you sure you want to recaluclate this metric?"})
        ])
      }, 'padding:5px;text-align:right;white-space:nowrap;']
    ]) %>

<% end %>